package cn.strive.eams.supplier.controller;

import cn.strive.eams.base.response.JsonResult;
import cn.strive.eams.supplier.pojo.dto.SupplierQuery;
import cn.strive.eams.supplier.pojo.dto.SupplierSaveParam;
import cn.strive.eams.supplier.pojo.vo.SupplierVO;
import cn.strive.eams.supplier.service.SupplierService;
import cn.strive.eams.virtual.pojo.dto.VirtualQuery;
import cn.strive.eams.virtual.pojo.dto.VirtualSaveParam;
import cn.strive.eams.virtual.pojo.vo.VirtualVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "供应商模块")
@RequestMapping("/v1/supplier")
public class SupplierController {
    @Autowired
    private SupplierService supplierService;

    @GetMapping("/select")
    public JsonResult selectSupplier(SupplierQuery supplierQuery){
        log.debug("查询供应商:supplierQuery={}",supplierQuery);
        List<SupplierVO> list = supplierService.selectSupplier(supplierQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("/save")
    public JsonResult saveSupplier(SupplierSaveParam supplierSaveParam){
        log.debug("保存供应商:supplierSaveParam={}",supplierSaveParam);
        supplierService.saveSupplier(supplierSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("/delete/{id}")
    public JsonResult deleteSupplier(@PathVariable Long id){
        log.debug("删除供应商:id={}",id);
        supplierService.deleteSupplier(id);
        return JsonResult.ok();
    }
    @PostMapping("/delete/batch/{ids}")
    @ApiOperation(value = "批量删除供应商")
    public JsonResult deleteBatch(@PathVariable List<Long> ids){
        log.info("批量删除供应商信息:ids={}", ids);
        supplierService.deleteBatch(ids);
        return JsonResult.ok();
    }
}
